package com.iatinspur.direct_memory;

import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.SocketChannel;
import java.nio.charset.StandardCharsets;

/**
 *
 */
public class WriteMemory {

    public static void main(String[] args) throws IOException {
        RandomAccessFile file =new RandomAccessFile("shared_memory", "rw");
        MappedByteBuffer buffer = file.getChannel().map(FileChannel.MapMode.READ_WRITE,0,1024);
        String data = "你好，黄飞";
        buffer.put(data.getBytes(StandardCharsets.UTF_8));
        System.in.read();


    }
}
